[6.x] Fix blank page when visiting CP routes with invalid items#14517
Merged
jasonvarga merged 2 commits into6.xfrom Apr 20, 2026
Merged
[6.x] Fix blank page when visiting CP routes with invalid items#14517jasonvarga merged 2 commits into6.xfrom
jasonvarga merged 2 commits into6.xfrom
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Visiting a CP URL with an invalid item (e.g.
/cp/collections/invalid,/cp/collections/blog/entries/missing-id, invalid terms, etc.) rendered a blank page with a JS error instead of a 404. Logged-out users hitting the same URLs also got the blank page instead of being redirected to login.Why
Route binders throw
NotFoundHttpExceptioninsideSubstituteBindings, which is in the outerstatamic.cpmiddleware group. That fires before the innerstatamic.cp.authenticatedgroup, soHandleAuthenticatedInertiaRequestsnever runs and the Inertia response is missing_statamic.sessionExpiry/nav. The default layout mountsSessionExpiry.vue, which destructures the missing prop →TypeError→ blank page.For the same reason,
Authorize(which normally redirects unauthenticated users to login) never gets a chance to run when the binder throws first.Changes
resources/js/pages/errors/404.vue— use theBlanklayout, matchingerrors/Error.vue. Error pages shouldn't depend on auth-only CP chrome props.src/Exceptions/Concerns/RendersHttpExceptions.php— when an HTTP exception fires on a CP route without a current user, returnAuthenticationException::toResponse()(login redirect) instead of rendering the error Inertia page. Matches whatAuthorizewould have produced.Note: the catch-all
/cp/{segments}404 route previously rendered inside the full CP chrome (it's declared insidestatamic.cp.authenticated, so auth middleware runs for it). With this change it renders on the blank layout too, making the two 404 paths consistent.Test plan
/cp/collections/invalid→ shows 404 page (no crash)/cp/collections/<valid>/entries/invalid→ shows 404 page (no crash)/cp/not-a-route→ shows 404 page/cp/collections/invalid→ redirects to login/cp/not-a-route→ redirects to login🤖 Generated with Claude Code